package controller

import (
	"errors"
	"github.com/gin-gonic/gin"
)

// 快速获取当前用户的 ID

func GetCurrentUser(c *gin.Context) (UserID uint64, err error) {
	uid, ok := c.Get("user_id")
	// 注意变量的接收方式，这里定义了一个中间变量 uid
	if !ok {
		err = errors.New("用户未登录！")
		return
	}
	UserID, ok = uid.(uint64)
	return

}
